package com.roundweigt;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "执行";
    ListView lv;
    List<String> list = new ArrayList<>();
    EditText et;
    TextView up;
    LinearLayout ly;
    ArrayAdapter<String> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        for (int i = 0; i < 30; i++) {

            list.add("第" + i + "条数据");
        }

        lv = findViewById(R.id.lv);
        up = findViewById(R.id.up);

        et = findViewById(R.id.et);

        ly = findViewById(R.id.ly);

        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
        lv.setAdapter(adapter);
        up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                list.add(et.getText().toString());
                adapter.notifyDataSetChanged();
               // lv.smoothScrollByOffset(adapter.getCount() - 1);


            }
        });







    }
}
